import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
//引入svg插件
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
// 引入mock插件
import { viteMockServe } from "vite-plugin-mock"; // 确保正确导入
// https://vite.dev/config/
export default defineConfig(({command})=>{
  return {
    // 路径别名
    resolve: {
      alias: {
        '@': path.resolve('./src'),
      },
    },
    plugins: [
      vue(),
      createSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
        symbolId: "icon-[dir]-[name]",
      }),
      // viteMockServe({
      //   //保证开发阶段用的是mock数据
      //   localEnabled:command==='serve'
      // }),
    ],
    
    // scss全局变量
    css: {
      preprocessorOptions: {
        scss: {
          javascriptEnabled: true,
          additionalData: `@use "@/styles/variable.scss" as *;`,
        },
      },
    },
    
  }
});
